package com.spring.aop.first.jdk;

import com.alibaba.fastjson.JSONObject;
import com.spring.aop.first.jdk.PayService;
import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.framework.ProxyFactory;

public class TestAopService {

    public static void main(String[] args) {
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setTarget(new PayService());
        proxyFactory.addAdvice((MethodInterceptor) in -> {
            Object[] agrus = in.getArguments();
            System.out.println(JSONObject.toJSONString(agrus));
            return in.proceed();
        });
        PayService payService = (PayService) proxyFactory.getProxy();
        payService.pay("微信支付");
    }
}
